/*
 * OptionsWindow.java
 *
 * Created on September 27, 2007, 4:46 PM
 */

package com.lct.eq2.gui;

import java.awt.Toolkit;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Properties;
import javax.swing.DefaultListModel;

/**
 *
 * @author  waitek
 */
public class OptionsWindow extends javax.swing.JFrame {
    private Properties props;
    private LiteGui parent;
    
    /** Creates new form OptionsWindow */
    public OptionsWindow(LiteGui parent) {
        this.setIconImage(Toolkit.getDefaultToolkit().getImage("eq2.png"));
        this.parent = parent;
        initComponents();
        
        this.respawnBeep.setVisible(false);
        this.autoRespawnPopup.setVisible(false);
        
        DefaultListModel model = new DefaultListModel();
        this.lstAlways.setModel(model);
        model = new DefaultListModel();
        this.lstNever.setModel(model);
        
        props = new Properties();
        try {
            props.load(new FileInputStream(new File("lct.properties")));
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        
        boolean eq2onSamePC = Boolean.parseBoolean(props.getProperty("eq2OnSamePC"));
        boolean respawnPopup = Boolean.parseBoolean(props.getProperty("respawnPopup"));
        boolean autoDisplayParsePreview = Boolean.parseBoolean(props.getProperty("autoDisplayParsePreview"));
        boolean autoDisplaySpellTimers = Boolean.parseBoolean(props.getProperty("autoDisplaySpellTimers"));
        boolean displayHPS = Boolean.parseBoolean(props.getProperty("displayHPS"));
        boolean displayDPS = Boolean.parseBoolean(props.getProperty("displayDPS"));
        boolean respawnBeep = Boolean.parseBoolean(props.getProperty("respawnBeep"));
        boolean autoVersionCheck = Boolean.parseBoolean(props.getProperty("autoVersionCheck"));
        
        String data = props.getProperty("sendData");
        boolean toSendData = true;
        if (data != null) {
            toSendData = Boolean.parseBoolean(data);
        }

        boolean parsePet = false;
        String parsePet_ = props.getProperty("parsePetDamage");
        if (parsePet_ != null) {
             parsePet = Boolean.parseBoolean(parsePet_);
        }

//        boolean parsePrevious = false;
//        String parsePrev = props.getProperty("parsePrevious");
//        if (parsePrev != null) {
//             parsePrevious = Boolean.parseBoolean(parsePrev);
//        }
        
        String copyBeep = props.getProperty("parseCopyBeep");
        boolean parseCopyBeep = false;
        
        if (copyBeep != null) {
            parseCopyBeep = Boolean.parseBoolean(copyBeep);
        }
        
//        String enableAttendance = props.getProperty("parseCustom");
//        boolean enableAtt = false;
//        if (enableAttendance != null) {
//            enableAtt = Boolean.parseBoolean(enableAttendance);
//        }
        
        String clearOnZoneChange = props.getProperty("zoneClear");
        boolean _zoneClear = false;
        if (clearOnZoneChange != null) {
            _zoneClear = Boolean.parseBoolean(clearOnZoneChange);
        }
        
        String whichAutoParse = props.getProperty("whichAutoParse");
        String fontName = props.getProperty("fontName");
        String fontSize = props.getProperty("fontSize");
        String dpsParsePrefix = props.getProperty("dpsParsePrefix");
        String healParsePrefix = props.getProperty("healParsePrefix");
        String maxPieGraph = props.getProperty("maxPieGraph");
        String waitTime = props.getProperty("secondsToWaitToEndEncounter");
//        String customAttendanceLine = null;
//        if (enableAtt) {
//            customAttendanceLine = props.getProperty("customLine");
//        }
        
//        this.enableAttendance.setSelected(enableAtt);
//        this.customLine.setEnabled(enableAtt);
//        this.customLine.setText(customAttendanceLine);
        
        this.parseCopyBeep.setSelected(parseCopyBeep);
        if (whichAutoParse != null) {
            this.whichAutoParse.setSelectedItem(whichAutoParse);
        }
        this.autoVersionCheck.setSelected(autoVersionCheck);
        this.txtWaitTime.setText(waitTime);
        this.txtMax.setText(maxPieGraph);
        this.respawnBeep.setSelected(respawnBeep);
        this.displayDps.setSelected(displayDPS);
        this.displayHps.setSelected(displayHPS);
        this.txtFont.setText(fontName);
        this.cmbFontSize.setSelectedItem(fontSize);
        this.autoParsePreview.setSelected(autoDisplayParsePreview);
        this.autoRespawnPopup.setSelected(respawnPopup);
        this.autoSpellTimer.setSelected(autoDisplaySpellTimers);
        this.eq2OnSamePC.setSelected(eq2onSamePC);
        this.txtDPSParse.setText(dpsParsePrefix);
        this.txtHealParse.setText(healParsePrefix);
//        this.parsePrevious.setSelected(parsePrevious);
        this.sendData.setSelected(toSendData);
        this.zoneClear.setSelected(_zoneClear);
        this.parsePetAsOwn.setSelected(parsePet);
        
        loadAbilityLists();
    }
    
    public void loadAbilityLists() {
        HashMap map = loadList();
        ArrayList always = (ArrayList)map.get("always");
        ArrayList never = (ArrayList)map.get("never");
        
        DefaultListModel model = (DefaultListModel)this.lstAlways.getModel();
        for (int x = 0; x < always.size(); x++) {
            model.addElement((String)always.get(x));
        }
        
        model = (DefaultListModel)this.lstNever.getModel();
        for (int x = 0; x < never.size(); x++) {
            model.addElement((String)never.get(x));
        }
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        autoParsePreview = new javax.swing.JCheckBox();
        autoRespawnPopup = new javax.swing.JCheckBox();
        autoSpellTimer = new javax.swing.JCheckBox();
        eq2OnSamePC = new javax.swing.JCheckBox();
        respawnBeep = new javax.swing.JCheckBox();
        jLabel13 = new javax.swing.JLabel();
        txtWaitTime = new javax.swing.JTextField();
        autoVersionCheck = new javax.swing.JCheckBox();
        parsePetAsOwn = new javax.swing.JCheckBox();
        sendData = new javax.swing.JCheckBox();
        zoneClear = new javax.swing.JCheckBox();
        jPanel1 = new javax.swing.JPanel();
        txtHealParse = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtDPSParse = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        whichAutoParse = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        parseCopyBeep = new javax.swing.JCheckBox();
        jPanel3 = new javax.swing.JPanel();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        cmbFontSize = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        txtFont = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        displayHps = new javax.swing.JCheckBox();
        displayDps = new javax.swing.JCheckBox();
        jPanel5 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        txtMax = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        lstNever = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        lstAlways = new javax.swing.JList();
        txtAlways = new javax.swing.JTextField();
        cmdAlways = new javax.swing.JButton();
        cmdNever = new javax.swing.JButton();
        txtNever = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("LCT Options");

        jButton1.setText("Save and Close");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        autoParsePreview.setText("Automatically Display Parse Preview Window");
        autoParsePreview.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        autoParsePreview.setMargin(new java.awt.Insets(0, 0, 0, 0));

        autoRespawnPopup.setText("Popup Message When a Respawn Should Occur");
        autoRespawnPopup.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        autoRespawnPopup.setEnabled(false);
        autoRespawnPopup.setMargin(new java.awt.Insets(0, 0, 0, 0));

        autoSpellTimer.setText("Automatically Display Spell Timer Window");
        autoSpellTimer.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        autoSpellTimer.setMargin(new java.awt.Insets(0, 0, 0, 0));

        eq2OnSamePC.setText("EQ2 is Running on the Same PC as LCT");
        eq2OnSamePC.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        eq2OnSamePC.setMargin(new java.awt.Insets(0, 0, 0, 0));
        eq2OnSamePC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eq2OnSamePCActionPerformed(evt);
            }
        });

        respawnBeep.setText("Play Beep Sound When a Respawn Should Occur");
        respawnBeep.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        respawnBeep.setEnabled(false);
        respawnBeep.setMargin(new java.awt.Insets(0, 0, 0, 0));

        jLabel13.setText("Seconds to Wait to End the Current Encounter:");

        autoVersionCheck.setText("Check For New LCT Version on Startup");
        autoVersionCheck.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        autoVersionCheck.setMargin(new java.awt.Insets(0, 0, 0, 0));

        parsePetAsOwn.setText("Parse Pet Damage as Your Own");
        parsePetAsOwn.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        parsePetAsOwn.setMargin(new java.awt.Insets(0, 0, 0, 0));

        sendData.setText("Send Parse Data to the LCT Web Stats Server");
        sendData.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        sendData.setMargin(new java.awt.Insets(0, 0, 0, 0));
        sendData.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sendDataActionPerformed(evt);
            }
        });

        zoneClear.setText("Clear Encounters on Zone Change");
        zoneClear.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        zoneClear.setMargin(new java.awt.Insets(0, 0, 0, 0));
        zoneClear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                zoneClearActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(eq2OnSamePC)
                    .add(autoParsePreview)
                    .add(autoVersionCheck)
                    .add(sendData)
                    .add(parsePetAsOwn)
                    .add(zoneClear)
                    .add(autoSpellTimer)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel13)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(txtWaitTime, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 29, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(autoRespawnPopup)
                    .add(respawnBeep))
                .addContainerGap(101, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(eq2OnSamePC)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(autoParsePreview)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(autoVersionCheck)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(sendData)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(zoneClear)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(parsePetAsOwn)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(autoSpellTimer)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel13)
                    .add(txtWaitTime, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(respawnBeep)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(autoRespawnPopup)
                .addContainerGap(30, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("General Options", jPanel2);
        jPanel2.getAccessibleContext().setAccessibleName("");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder()));

        jLabel2.setText("Channel For Copying Heal Parse:");

        jLabel1.setText("Channel For Copying Damage Parse:");

        jLabel4.setText("s for say, r for raid");

        jLabel5.setText("g for group, gu for guild");

        jLabel6.setText("t Character to tell");

        jLabel3.setText("Examples:");

        whichAutoParse.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "DPS Parse", "Heal Parse" }));

        jLabel14.setText("Automatically Copy:");

        parseCopyBeep.setText("Beep When a Parse is Copied");
        parseCopyBeep.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        parseCopyBeep.setMargin(new java.awt.Insets(0, 0, 0, 0));

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                        .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(jPanel1Layout.createSequentialGroup()
                            .add(jLabel2)
                            .add(18, 18, 18))
                        .add(txtHealParse, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 165, Short.MAX_VALUE)
                        .add(txtDPSParse))
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(15, 15, 15)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(jLabel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jLabel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .add(jLabel3)
                    .add(jLabel14)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(whichAutoParse, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 108, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(32, 32, 32)
                        .add(parseCopyBeep)))
                .addContainerGap(56, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(txtDPSParse, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(txtHealParse, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel3)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel4)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel5)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel6)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 23, Short.MAX_VALUE)
                .add(jLabel14)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(whichAutoParse, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(parseCopyBeep))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Parse Copy Options", jPanel1);

        cmbFontSize.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18" }));

        jLabel9.setText("Size:");

        jLabel8.setText("Font:");

        jLabel7.setText("Format:");

        displayHps.setText("Display Total Healing Done");
        displayHps.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        displayHps.setMargin(new java.awt.Insets(0, 0, 0, 0));

        displayDps.setText("Display Damage Per Second");
        displayDps.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        displayDps.setMargin(new java.awt.Insets(0, 0, 0, 0));

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(10, 10, 10)
                        .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel8)
                            .add(jLabel9))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(txtFont, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 138, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(cmbFontSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(displayDps)
                    .add(jLabel7)
                    .add(displayHps))
                .addContainerGap(182, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(displayDps)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(displayHps, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 15, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel7)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel8)
                    .add(txtFont, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel9)
                    .add(cmbFontSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(119, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Bar Graph", jPanel4);

        jLabel10.setText("Max Number of Items to Graph:");

        txtMax.setText("20");

        lstNever.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        lstNever.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                lstNeverKeyPressed(evt);
            }
        });
        lstNever.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                lstNeverMouseReleased(evt);
            }
        });
        jScrollPane1.setViewportView(lstNever);

        lstAlways.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        lstAlways.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                lstAlwaysKeyPressed(evt);
            }
        });
        lstAlways.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lstAlwaysMouseClicked(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                lstAlwaysMouseReleased(evt);
            }
        });
        jScrollPane2.setViewportView(lstAlways);

        cmdAlways.setText("Add");
        cmdAlways.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdAlwaysActionPerformed(evt);
            }
        });

        cmdNever.setText("Add");
        cmdNever.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmdNeverActionPerformed(evt);
            }
        });

        jLabel11.setText("Always Graph These Abilities:");

        jLabel12.setText("Never Graph These Abilities:");

        org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(jPanel5Layout.createSequentialGroup()
                                .add(txtAlways, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 103, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(cmdAlways))
                            .add(jLabel11)
                            .add(jScrollPane2, 0, 0, Short.MAX_VALUE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 22, Short.MAX_VALUE)
                        .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel12)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                .add(jPanel5Layout.createSequentialGroup()
                                    .add(txtNever, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(cmdNever))
                                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE))))
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(jLabel10)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(txtMax, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 31, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel10)
                    .add(txtMax, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 58, Short.MAX_VALUE)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel11)
                    .add(jLabel12))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(cmdNever)
                    .add(txtNever, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(txtAlways, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(cmdAlways))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jScrollPane2, 0, 0, Short.MAX_VALUE)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 91, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jTabbedPane2.addTab("Pie Graph", jPanel5);

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jTabbedPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jTabbedPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Graph Options", jPanel3);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap(271, Short.MAX_VALUE)
                .add(jButton1))
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 290, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton1))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cmdNeverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdNeverActionPerformed
        DefaultListModel model = (DefaultListModel)lstNever.getModel();
        model.addElement(this.txtNever.getText());
        this.txtNever.setText("");
    }//GEN-LAST:event_cmdNeverActionPerformed

    private void lstAlwaysMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lstAlwaysMouseClicked
    }//GEN-LAST:event_lstAlwaysMouseClicked

    private void lstNeverMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lstNeverMouseReleased
    }//GEN-LAST:event_lstNeverMouseReleased

    private void lstAlwaysMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lstAlwaysMouseReleased
    }//GEN-LAST:event_lstAlwaysMouseReleased

    private void lstNeverKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lstNeverKeyPressed
        int index = lstNever.getSelectedIndex();
        
        if (evt.getKeyText(evt.getKeyCode()).equalsIgnoreCase("Delete")) {
            this.deleteNeverAbility(index);
        }
    }//GEN-LAST:event_lstNeverKeyPressed

    private void lstAlwaysKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lstAlwaysKeyPressed
        int index = lstAlways.getSelectedIndex();
        DefaultListModel model = (DefaultListModel)this.lstAlways.getModel();
        
        if (evt.getKeyText(evt.getKeyCode()).equalsIgnoreCase("Delete")) {
            this.deleteAlwaysAbility(index);
        }
    }//GEN-LAST:event_lstAlwaysKeyPressed
    
    private void eq2OnSamePCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eq2OnSamePCActionPerformed
        if (this.eq2OnSamePC.isSelected()) {
            this.autoParsePreview.setEnabled(false);
            this.autoParsePreview.setSelected(false);
            //this.autoRespawnPopup.setEnabled(false);
            //this.autoRespawnPopup.setSelected(false);
            this.autoSpellTimer.setEnabled(false);
            this.autoSpellTimer.setSelected(false);
        } else {
            this.autoParsePreview.setEnabled(true);
            //this.autoRespawnPopup.setEnabled(true);
            this.autoSpellTimer.setEnabled(true);
        }
    }//GEN-LAST:event_eq2OnSamePCActionPerformed

    private void cmdAlwaysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdAlwaysActionPerformed
        DefaultListModel model = (DefaultListModel)lstAlways.getModel();
        model.addElement(this.txtAlways.getText());
        this.txtAlways.setText("");
    }//GEN-LAST:event_cmdAlwaysActionPerformed

    private void deleteNeverAbility(int index) {
        if (index >= 0) {
            DefaultListModel model = (DefaultListModel)this.lstNever.getModel();
            model.remove(index);
        }
    }
    
    private void deleteAlwaysAbility(int index) {
        if (index >= 0) {
            DefaultListModel model = (DefaultListModel)this.lstAlways.getModel();
            model.remove(index);
        }
    }
    
    private void storeAlwaysAbilities() {
        HashMap map = loadList();
        ArrayList list = new ArrayList();
        DefaultListModel model = (DefaultListModel)this.lstAlways.getModel();
        for (int x = 0; x < model.getSize(); x++) {
            String tmp = (String)model.get(x);
            if (!list.contains(tmp)) {
                list.add(tmp);
            }
        }
        map.put("always", list);
        storeList(map);
    }
    
    private void storeNeverAbilities() {
        HashMap map = loadList();
        ArrayList list = new ArrayList();
        DefaultListModel model = (DefaultListModel)this.lstNever.getModel();
        for (int x = 0; x < model.getSize(); x++) {
            String tmp = (String)model.get(x);
            list.add(tmp);
        }
        map.put("never", list);
        storeList(map);
    }
    
    private void storeList(HashMap map) {
        try {
            FileOutputStream fos = new FileOutputStream("list.dat");
            ObjectOutputStream oos = new ObjectOutputStream(fos);
            oos.writeObject(map);
            fos.close();
            oos.close();
        } catch (FileNotFoundException ex) {
            // nothing
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
    
    private HashMap loadList() {
        HashMap rval = null;
        try {
            FileInputStream fis = new FileInputStream("list.dat");
            ObjectInputStream ois = new ObjectInputStream(fis);
            rval = (HashMap)ois.readObject();
            fis.close();
            ois.close();
        } catch (FileNotFoundException ex) {
            rval = new HashMap();
            rval.put("always", new ArrayList());
            rval.put("never", new ArrayList());
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
        return rval;
    }
    
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        try {
            this.storeAlwaysAbilities();
            this.storeNeverAbilities();
//            this.props.setProperty("parseCustom", this.enableAttendance.isSelected() + "");
//            this.props.setProperty("customLine", this.customLine.getText());
            this.props.setProperty("whichAutoParse", (String)this.whichAutoParse.getSelectedItem());
            this.props.setProperty("autoVersionCheck", this.autoVersionCheck.isSelected() + "");
            this.props.setProperty("secondsToWaitToEndEncounter", this.txtWaitTime.getText());
            this.props.setProperty("maxPieGraph", this.txtMax.getText());
            this.props.setProperty("dpsParsePrefix", this.txtDPSParse.getText());
            this.props.setProperty("healParsePrefix", this.txtHealParse.getText());
            this.props.setProperty("fontName", this.txtFont.getText());
            this.props.setProperty("fontSize", (String)this.cmbFontSize.getSelectedItem());
            this.props.setProperty("warOnSamePC", this.eq2OnSamePC.isSelected() + "");
            this.props.setProperty("respawnPopup", this.autoRespawnPopup.isSelected() + "");
            this.props.setProperty("autoDisplaySpellTimers", this.autoSpellTimer.isSelected() + "");
            this.props.setProperty("autoDisplayParsePreview", this.autoParsePreview.isSelected() + "");
            this.props.setProperty("displayDPS", this.displayDps.isSelected() + "");
            this.props.setProperty("displayHPS", this.displayHps.isSelected() + "");
            this.props.setProperty("respawnBeep", this.respawnBeep.isSelected() + "");
            this.props.setProperty("parseCopyBeep", this.parseCopyBeep.isSelected() + "");
//            this.props.setProperty("parsePrevious", this.parsePrevious.isSelected() + "");
            this.props.setProperty("parsePetDamage", this.parsePetAsOwn.isSelected() + "");
            this.props.setProperty("sendData", this.sendData.isSelected() + "");
            this.props.setProperty("zoneClear", this.zoneClear.isSelected() + "");
            
            FileOutputStream out = new FileOutputStream("lct.properties");
            this.props.store(out, "updated");
            out.close();
            this.parent.propertiesUpdated();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        this.dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

private void sendDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendDataActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_sendDataActionPerformed

private void zoneClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoneClearActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_zoneClearActionPerformed
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox autoParsePreview;
    private javax.swing.JCheckBox autoRespawnPopup;
    private javax.swing.JCheckBox autoSpellTimer;
    private javax.swing.JCheckBox autoVersionCheck;
    private javax.swing.JComboBox cmbFontSize;
    private javax.swing.JButton cmdAlways;
    private javax.swing.JButton cmdNever;
    private javax.swing.JCheckBox displayDps;
    private javax.swing.JCheckBox displayHps;
    private javax.swing.JCheckBox eq2OnSamePC;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JList lstAlways;
    private javax.swing.JList lstNever;
    private javax.swing.JCheckBox parseCopyBeep;
    private javax.swing.JCheckBox parsePetAsOwn;
    private javax.swing.JCheckBox respawnBeep;
    private javax.swing.JCheckBox sendData;
    private javax.swing.JTextField txtAlways;
    private javax.swing.JTextField txtDPSParse;
    private javax.swing.JTextField txtFont;
    private javax.swing.JTextField txtHealParse;
    private javax.swing.JTextField txtMax;
    private javax.swing.JTextField txtNever;
    private javax.swing.JTextField txtWaitTime;
    private javax.swing.JComboBox whichAutoParse;
    private javax.swing.JCheckBox zoneClear;
    // End of variables declaration//GEN-END:variables
    
}
